package dtt;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;



import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class FrontController extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public FrontController() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 * 
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request
	 *            the request send by the client to the server
	 * @param response
	 *            the response send by the server to the client
	 * @throws ServletException
	 *             if an error occurred
	 * @throws IOException
	 *             if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 * 
	 * This method is called when a form has its tag value method equals to
	 * post.
	 * 
	 * @param request
	 *            the request send by the client to the server
	 * @param response
	 *            the response send by the server to the client
	 * @throws ServletException
	 *             if an error occurred
	 * @throws IOException
	 *             if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String action = request.getParameter("DTT_ACTION");
	//	DefectBean defect1 = null;
		String page = null;
		System.out.println("action =" + action);

		if (action.equals("USER_LOGIN")) {
			
			UserBean userbean = new UserBean();
			String userId = request.getParameter("userId");
			String userPassword = request.getParameter("userPassword");
			UserBean userbean1 = null;
			
			// super user logged on
			if (userId.equals("superuser") && userPassword.equals("comp474"))
			{
				page = "/superuser1.jsp?filename=c:\\uploads\\pic5.bmp";
				request.setAttribute("filename", "c:\\uploads\\pic5.bmp");
				request.getRequestDispatcher(page).forward(request, response);
				return;
			}
			
			if (!(userId.equals("") || userPassword.equals(""))) {
				userbean.setUserName(userId);
				userbean.setUserPassword(userPassword);
				SecurityBO securitybo = new SecurityBO();
				userbean1 = securitybo.authenticateUser(userbean);

				if (userbean1 != null) {
					System.out.println("User bean did not return null");
					HttpSession session = request.getSession(false);
					if (session != null) {
						session.invalidate(); // Remove the old session object
					}
					session = request.getSession(true); // create a new session
														// for the user
					System.out.println("userbean1 userId is"
							+ userbean1.getUserName());
					System.out.println("userbean1 role is"
							+ userbean1.getUserRole());
					session.setAttribute("userbean", userbean1);
					// Get the list of the projects assigned to the user
					ProjectBO projectbo = new ProjectBO();
					ArrayList projectList = null;
					projectList = projectbo.getAssignedProjects(userbean1.getUserId());
					request.setAttribute("projectBeanList", projectList);
					request.getSession().removeAttribute("current_project");
					if (projectList != null) {
						page = "/ProjectListContainer.jsp";
					} else {
						String error = "User has not been assigned any projects currently";
						ErrorBean errorbean = new ErrorBean();
						errorbean.setMessage(error);
						request.setAttribute("errorbean", errorbean);
						page = "/ErrorDisplayContainer.jsp";
					}
				}// end if valid user
				else {
					String error = "Please provide a valid user name and password";
					ErrorBean errorbean = new ErrorBean();
					errorbean.setMessage(error);
					request.setAttribute("errorbean", errorbean);
					page = "/ErrorDisplayContainer.jsp";

				}// end else
			}// end if
			else {
				String error = "Please provide a valid user name and password";
				ErrorBean errorbean = new ErrorBean();
				errorbean.setMessage(error);
				request.setAttribute("errorbean", errorbean);
				page = "/ErrorDisplayContainer.jsp";

			}// end else

			request.getRequestDispatcher(page).forward(request, response);

		}

		if (action.equals("VIEW_DEFECT")) {

			DefectBean defectbean = null;
			ProjectBean projectbean = null;

			String defectId = request.getParameter("defectId");
			String projectId = request.getParameter("projectId");
			try {
				ProjectBO projectBo = new ProjectBO();
				projectbean = projectBo.getProjectDetails(projectId);
				DefectBO defectBO = new DefectBO();
				defectbean = defectBO.getDefectDetail(projectId, defectId);
				//defectbean.setDefectDesc("i do not know why");

			}// end of try block
			catch (SQLException e) {
				e.printStackTrace();
			}// end of catch block
			request.setAttribute("defectbean", defectbean);
			request.setAttribute("projectbean", projectbean);
			request.getRequestDispatcher("/DisplayDefectContainer.jsp")
					.forward(request, response);
		}// end of if condition VIEW_DEFECT

		if (action.equals("DEFECT_LIST")) {
			String projectId = request.getParameter("projectId");
			if(projectId == null){
				projectId = (String)request.getSession().getAttribute("current_project"); ;
			}//end if projectId is null
			System.out.println("ProjectId in DEFECT_LIST is"+projectId);
			DefectBO defectbo = new DefectBO();
			ArrayList defectList = null;
			defectList = defectbo.getDefectList(projectId);
			request.setAttribute("defectList", defectList);
			request.getSession().setAttribute("current_project", projectId);
			request.getRequestDispatcher("/DefectListContainer.jsp").forward(
					request, response);
		}

		if (action.equals("VIEW_UPDATABLE_FORM")) {

			DefectBean defectbean = null;
			ProjectBean projectbean = null;

			String defectId = request.getParameter("defectId");
			String projectId = request.getParameter("projectId");
			UserBean userbean = (UserBean) request.getSession().getAttribute(
					"userbean");
			try {
				ProjectBO projectBo = new ProjectBO();
				projectbean = projectBo.getProjectDetails(projectId);

				DefectBO defectBO = new DefectBO();
				defectbean = defectBO.getDefectDetail(projectId, defectId);

				BusinessRulesBO businessRulesBo = new BusinessRulesBO();
				ArrayList stateList = businessRulesBo.getValidStateTransitions(
						defectbean.getDefectStatus(), userbean.getUserRole());
				defectbean.setValidFutureStates(stateList);

			}// end of try block
			catch (SQLException e) {
				e.printStackTrace();
			}// end of catch block

			request.setAttribute("defectbean", defectbean);
			request.setAttribute("projectbean", projectbean);

			request.getRequestDispatcher("/UpdateDefectContainer.jsp").forward(
					request, response);

		}

		if (action.equals("UPDATE_DEFECT")) {
			String defectId = request.getParameter("defectId");
			String projectId = request.getParameter("projectId");

			DefectBean defectbean = new DefectBean();
			defectbean.setDefectId(defectId);
			defectbean.setProjectId(request.getParameter("projectId"));
			defectbean.setRequirementId(request.getParameter("requirementId"));
			defectbean.setTestScriptId(request.getParameter("testScriptId"));
			defectbean.setDefectStatus(request.getParameter("defectStatus"));
			defectbean
					.setDefectSeverity(request.getParameter("defectSeverity"));
			defectbean
					.setDefectPriority(request.getParameter("defectPriority"));
			defectbean.setDefectLastUpdatedBy(request
					.getParameter("defectLastUpdatedBy"));
			defectbean.setDefectAssignedto(request
					.getParameter("defectAssignedto"));
			defectbean.setDefectReproducibility(request
					.getParameter("defectReproducibility"));
			defectbean.setDefectProductVerNbr(request
					.getParameter("defectProductVerNbr"));
			defectbean
					.setDefectBuildNbr(request.getParameter("defectBuildNbr"));
			defectbean.setDefectTgtVerNbr(request
					.getParameter("defectTgtVerNbr"));
			defectbean.setDefectFixedinVerNbr(request
					.getParameter("defectFixedinVerNbr"));
			defectbean.setDefectDesc(request.getParameter("defectDesc"));
			defectbean.setDefectStepstoReproduce(request
					.getParameter("defectStepstoReproduce"));
			defectbean.setDefectDevFixCom(request
					.getParameter("defectDevFixCom"));

			DefectBean outputbean = null;
			ProjectBean projectbean = null;

			try {

				DefectBO defectBO = new DefectBO();
				outputbean = defectBO.updateDefect(defectbean);

				ProjectBO projectBo = new ProjectBO();
				projectbean = projectBo.getProjectDetails(projectId);
			} catch (Exception e) {
				e.printStackTrace();
			}
			request.setAttribute("defectbean", outputbean);
			request.setAttribute("projectbean", projectbean);

			request.getRequestDispatcher("/DisplayDefectContainer.jsp")
					.forward(request, response);
		}

		// add a project
		if (action.equals("ADD_PRJ_FORM")) {
			ProjectBO projectBo = new ProjectBO();
			String projectId = projectBo.generateProjectId();
			System.out.println("defect id generated is " + projectId);
				ProjectBean projectbean = null;
			try {
				projectbean = new ProjectBean();
				projectbean.setProjectNbr(projectId);

			} catch (Exception e) {
				e.printStackTrace();
			}
			request.setAttribute("projectbean", projectbean);


			request.getRequestDispatcher("/AddProjectContainer.jsp").forward(
					request, response);
		} // end if action ADD_PRJ_FORM
		
		// PROJECT_EDIT_FORM
		if (action.equals("PROJECT_EDIT_FORM")) {
			ProjectBO projectBo = new ProjectBO();
			String projectNbr = request.getParameter("projectId");
			System.out.println("defect id generated is " + projectNbr);
				ProjectBean projectbean = null;
			try {
				projectbean = projectBo.getProjectDetails(projectNbr);
				//projectbean.setProjectNbr(projectNbr);

			} catch (Exception e) {
				e.printStackTrace();
			}
			request.setAttribute("projectbean", projectbean);
			request.getRequestDispatcher("/UpdateProjectContainer.jsp").forward(
					request, response);
		} // end if action End_PRJ_FORM
		
		// 
		if (action.equals("SEARCH_DEFECT_FORM")) {
			UserBean userbean= (UserBean) request.getSession().getAttribute("userbean");
			ProjectBO projectbo = new ProjectBO();
			ArrayList projectList = null;
			projectList = projectbo.getAssignedProjects(userbean.getUserId());
			
			request.setAttribute("projectBeanList", projectList);				
			   page = "/SearchDefectContainer.jsp";
				request.getRequestDispatcher(page).forward(request, response);
			
		}// end if action SEARCH_DEFECT
		
		if (action.equals("SEARCH_DEFECT")) {
			UserBean userbean= (UserBean) request.getSession().getAttribute("userbean");
			int userId = userbean.getUserId();
			
			SearchCriteria criteria = new SearchCriteria();
			String projectId=request.getParameter("projectId");
			String defectId=request.getParameter("defectId");
			String severity=request.getParameter("severity");
			String defectStatus=request.getParameter("defectStatus");
			String priority=request.getParameter("priority");
			String assignedTo=request.getParameter("assignedTo");
			String reportedBy=request.getParameter("reportedBy");
			String dateSubmitted=request.getParameter("dateSubmitted");
			String description=request.getParameter("description");			
			
			
			if(!"Select".equals(projectId)){
				 criteria.setProjectId(projectId);
			}
			if(!"".equals(defectId)){
			 criteria.setDefectId(defectId);
			}
			if(!"".equals(reportedBy)){
				 criteria.setReportedBy(reportedBy);
			}			
			if(!"".equals(dateSubmitted)){
				 criteria.setDateSubmitted(dateSubmitted);
			}			
			if(!"Select".equals(severity)){
				 criteria.setSeverity(severity);
			}
			if(!"Select".equals(priority)){
				 criteria.setPriority(priority);
			}			
			if(!"".equals(assignedTo)){
				 criteria.setAssignedTo(assignedTo);
			}
			if(!"Select".equals(defectStatus)){
				 criteria.setDefectStatus(defectStatus);
			}			
			if(!"".equals(description)){
				 criteria.setDescription(description);
			}
			DefectBO defectBO = new DefectBO();
			ArrayList defectList = defectBO.searchDefect(criteria);
			request.setAttribute("defectList", defectList);
			
			ProjectBO projectbo = new ProjectBO();
			ArrayList projectList = null;
			projectList = projectbo.getAssignedProjects(userId);
			request.setAttribute("searchCriteria", criteria);
			request.setAttribute("projectBeanList", projectList);				
			   page = "/SearchDefectContainer.jsp";
				request.getRequestDispatcher(page).forward(request, response);
			
		}// end if action SEARCH_DEFECT
	
		
		// action of add project
		if (action.equals("ADD_PROJECT")){
			ProjectBean projectbean = new ProjectBean();
			ProjectBO projectbo = new ProjectBO();
			
			projectbean.setProjectNbr(request.getParameter("projectId"));
			projectbean.setProjectDesc(request.getParameter("projectDesc"));
			projectbean.setProjectCategory(request.getParameter("projectCategory"));
			projectbean.setProjectVernbr(request.getParameter("projectVernbr"));
			projectbo.addProject(projectbean);
			System.out.println(projectbean.getProjectCategory());
			System.out.println(projectbean.getProjectVernbr());
			
			ArrayList projectList = null;
			UserBean userbean1  = (UserBean)request.getSession().getAttribute("userbean");
			//ProjectBO projectbo = new ProjectBO();
			projectList = projectbo.getAssignedProjects(userbean1.getUserId());
			request.setAttribute("projectBeanList", projectList);
			request.getSession().removeAttribute("current_project");

			page = "/ProjectListContainer.jsp";
			request.getRequestDispatcher(page).forward(request, response);
		} // end of adding project

		// UPDATE_PROJECT
		if (action.equals("UPDATE_PROJECT")){
			ProjectBean projectbean = new ProjectBean();
			ProjectBO projectbo = new ProjectBO();
			projectbean.setProjectId(Integer.parseInt(request.getParameter("projectId")));
			projectbean.setProjectNbr(request.getParameter("projectNbr"));
			projectbean.setProjectDesc(request.getParameter("projectDesc"));
			projectbean.setProjectCategory(request.getParameter("projectCategory"));
			projectbean.setProjectVernbr(request.getParameter("projectVernbr"));
			projectbo.updateProject(projectbean);
			System.out.println(projectbean.getProjectCategory());
			System.out.println(projectbean.getProjectVernbr());
			
			ArrayList projectList = null;
			UserBean userbean1  = (UserBean)request.getSession().getAttribute("userbean");
			//ProjectBO projectbo = new ProjectBO();
			projectList = projectbo.getAssignedProjects(userbean1.getUserId());
			request.setAttribute("projectBeanList", projectList);
			request.getSession().removeAttribute("current_project");

			page = "/ProjectListContainer.jsp";
			request.getRequestDispatcher(page).forward(request, response);
		} // end of adding project
		
		// End of update project
		
		// add a team member form ADD_TEAMMEMBER_FORM
		if (action.equals("ADD_TEAMMEMBER_FORM")) {
			ProjectBO projectBo = new ProjectBO();
			String projectId = projectBo.generateProjectId();
			System.out.println("defect id generated is " + projectId);
				ProjectBean projectbean = null;
			try {
				projectbean = new ProjectBean();
				projectbean.setProjectNbr(projectId);

			} catch (Exception e) {
				e.printStackTrace();
			}
			request.setAttribute("projectbean", projectbean);

			request.getRequestDispatcher("/AddTeamMemberContainer.jsp").forward(
					request, response);
		} // end of add a team member form

		// add a team member form ADD_TEAMMEMBER
		if (action.equals("ADD_TEAMMEMBER")) {
			UserBean userbean1  = (UserBean)request.getSession().getAttribute("userbean");
			userbean1.addTeamMember(request.getParameter("userName"),
					request.getParameter("userPassword"),
					request.getParameter("userEmail"),
					request.getParameter("userTel"),
					request.getParameter("userAddress"),
					request.getParameter("userInfo"));
			
			ProjectBO projectbo = new ProjectBO();
			ArrayList projectList = null;
			//ProjectBO projectbo = new ProjectBO();
			projectList = projectbo.getAssignedProjects(userbean1.getUserId());
			request.setAttribute("projectBeanList", projectList);
			request.getSession().removeAttribute("current_project");

			page = "/ProjectListContainer.jsp";
			request.getRequestDispatcher(page).forward(request, response);
		} // end of add a team member

		// add a team member form ADD_TEAMMEMBER_FORM
		if (action.equals("PROFILE_FORM")) {
			UserBean userbean1  = (UserBean)request.getSession().getAttribute("userbean");
			ProjectBO projectBo = new ProjectBO();
			String projectId = projectBo.generateProjectId();
			ArrayList profile =null;
			profile = userbean1.getUserDetail();
			ProjectBean projectbean = null;
			try {
				projectbean = new ProjectBean();
				projectbean.setProjectNbr(projectId);

			} catch (Exception e) {
				e.printStackTrace();
			}

			request.setAttribute("profile", profile);
			
			request.setAttribute("projectbean", projectbean);
			request.setAttribute("userbean", userbean1);
			request.getRequestDispatcher("/UpdateProfileContainer.jsp").forward(
					request, response);
		} // end of add a team member form
		
		// add a team member form ADD_TEAMMEMBER_FORM
		if (action.equals("PROFILECHANGE")) {
			UserBean userbean1  = (UserBean)request.getSession().getAttribute("userbean");
			userbean1.updateTeamMember(request.getParameter("userName"),
					request.getParameter("userPassword"),
					request.getParameter("userEmail"),
					request.getParameter("userTel"),
					request.getParameter("userAddress"),
					request.getParameter("userInfo"));
			
			ProjectBO projectbo = new ProjectBO();
			ArrayList projectList = null;
			//ProjectBO projectbo = new ProjectBO();
			projectList = projectbo.getAssignedProjects(userbean1.getUserId());
			request.setAttribute("projectBeanList", projectList);
			request.getSession().removeAttribute("current_project");

			page = "/ProjectListContainer.jsp";
			request.getRequestDispatcher(page).forward(request, response);
		} // end of add a team member form

		// Add role/project/user manage MANAGER_FORM
		if (action.equals("MANAGER_FORM")){
			ProjectBO projectBo = new ProjectBO();
			UserBean userBo = new UserBean();
			ArrayList projectList = null;
			ArrayList userList = null;
			ArrayList roleList = null;
			ArrayList roledetailList = null;
			projectList = projectBo.getProjects();
			userList = userBo.getUsers();
			roleList = userBo.getRoles();
			roledetailList = userBo.getDetailRoles();
			request.setAttribute("projectBeanList", projectList);
			request.setAttribute("userBeanList", userList);
			request.setAttribute("roleBeanList", roleList);
			request.setAttribute("detailRoleList", roledetailList);
			String projectId = projectBo.generateProjectId();
				ProjectBean projectbean = null;
			try {
				projectbean = new ProjectBean();
				projectbean.setProjectNbr(projectId);

			} catch (Exception e) {
				e.printStackTrace();
			}
			request.setAttribute("projectbean", projectbean);

			request.getRequestDispatcher("/ManageRoleContainer.jsp").forward(
					request, response);
			
		}// MANAGE
		
		// ADD ROLE MANAGE_ROLE
		
		if (action.equals("MANAGE_ROLE")) {
			UserBean userbean1  = (UserBean)request.getSession().getAttribute("userbean");
			userbean1.addRole(request.getParameter("projectselectitem"),
					request.getParameter("userselectitem"),
					request.getParameter("roleselectitem"),
					request.getParameter("newrole"));
			
			ProjectBO projectbo = new ProjectBO();
			ArrayList projectList = null;
			//ProjectBO projectbo = new ProjectBO();
			projectList = projectbo.getAssignedProjects(userbean1.getUserId());
			request.setAttribute("projectBeanList", projectList);
			request.getSession().removeAttribute("current_project");

			page = "/ProjectListContainer.jsp";
			request.getRequestDispatcher(page).forward(request, response);
		} 
		// END OF ADD ROLE
		
		// Delete roles
		if (action.equals("DEL_ROLE")) {
			UserBean userbean1  = (UserBean)request.getSession().getAttribute("userbean");
			userbean1.delRole(request.getParameter("roleselected"));
			System.out.println("del role:" + request.getParameter("roleselected"));
			ProjectBO projectbo = new ProjectBO();
			ArrayList projectList = null;
			//ProjectBO projectbo = new ProjectBO();
			projectList = projectbo.getAssignedProjects(userbean1.getUserId());
			request.setAttribute("projectBeanList", projectList);
			request.getSession().removeAttribute("current_project");

			page = "/ProjectListContainer.jsp";
			request.getRequestDispatcher(page).forward(request, response);
		} 
		// END OF ADD ROLE
		
// Add a defect under the current project information
		if (action.equals("ADD_DEFECT_FORM")) {
			DefectBO defectbo = new DefectBO();
			String projectId = (String) request.getSession().getAttribute(
					"current_project");
			String defectId = defectbo.generateDefectId(projectId);
			System.out.println("defect id generated is " + defectId);
			DefectBean defectbean = new DefectBean();
			defectbean.setDefectId(defectId);
			System.out
					.println("FrontController: current_project: " + projectId);
			ProjectBean projectbean = null;
			try {
				ProjectBO projectBo = new ProjectBO();
				projectbean = projectBo.getProjectDetails(projectId);

			} catch (Exception e) {
				e.printStackTrace();
			}
			request.setAttribute("projectbean", projectbean);
			request.setAttribute("defectbean", defectbean);

			request.getRequestDispatcher("/AddDefectContainer.jsp").forward(
					request, response);
		} // end if action ADD_DEFECT_FORM

		// action of add defect
		if (action.equals("ADD_DEFECT")) {

			DefectBean defectbean = new DefectBean();
			DefectBO defectbo = new DefectBO();
			boolean flag = false;
			String projectId = request.getParameter("projectId");
			String defectId = request.getParameter("defectId");
			String defectStatus = request.getParameter("defectStatus");
			System.out
					.println("Defect Status from add defect =" + defectStatus);
			ArrayList defectList = null;

			// To generate a dynamic defect ID

			defectbean.setProjectId(projectId);
			defectbean.setDefectId(defectId);
			defectbean.setDefectDesc(request.getParameter("defectDesc"));
			defectbean.setRequirementId(request.getParameter("requirementId"));
			defectbean.setTestScriptId(request.getParameter("scriptIdnumber"));
			defectbean.setDefectSeverity(request.getParameter("defectSeverity"));
			defectbean.setDefectStatus(request.getParameter("defectStatus"));
//
			defectbean.setDefectBuildNbr(request.getParameter("defectBuildNbr"));
			defectbean.setDefectDevFixCom(request.getParameter("defectDevFixComments"));
			defectbean.setDefectFixedinVerNbr(request.getParameter("defectFixedinVerNbr"));
			defectbean.setDefectId(request.getParameter("defectId"));
			defectbean.setDefectLastUpdatedBy(request.getParameter("defectLastUpdatedBy"));
			defectbean.setDefectPriority(request.getParameter("defectPriority"));
			defectbean.setDefectProductVerNbr(request.getParameter("defectProductVerNbr"));
			defectbean.setDefectReportedBy(request.getParameter("defectReporterName"));
			defectbean.setDefectReproducibility(request.getParameter("defectReproducibility"));
			defectbean.setDefectSeverity(request.getParameter("defectSeverity"));
			defectbean.setDefectStatus(request.getParameter("defectStatus"));
			defectbean.setDefectStepstoReproduce(request.getParameter("defectStepstoReproduce"));
			defectbean.setDefectTgtVerNbr(request.getParameter("defectTgtVerNbr"));
			
			//
			try {
				DefectBO defectBO = new DefectBO();
				flag = defectBO.addDefect(defectbean);
				defectBO.sendMail("horace.ht.zhang@gmail.com", "from DTT", "this is for testing message body", "hzhang9@luc.edu");
				if (flag) {
					// DefectBO defectbo = new DefectBO();
					defectList = defectbo.getDefectList(projectId);
				}// end if flag
			} catch (Exception e) {
				e.printStackTrace();
			}

			request.setAttribute("defectList", defectList);
			request.getSession().setAttribute("current_project", projectId);
			request.getRequestDispatcher("/DefectListContainer.jsp").forward(
					request, response);

		}// end of if action "ADD_DEFECT"

		if (action.equals("PROJECT_LIST")) {
			UserBean userbean= (UserBean) request.getSession().getAttribute("userbean");
			String userId = userbean.getUserName();
			System.out.println("In action projectlist the username obtained is "+userId);
			// Get the list of the projects assigned to the user
			ProjectBO projectbo = new ProjectBO();
			ArrayList projectList = null;
			projectList = projectbo.getAssignedProjects(userbean.getUserId());
			request.setAttribute("projectBeanList", projectList);
			request.getSession().removeAttribute("current_project");
			if (projectList != null) {
				page = "/ProjectListContainer.jsp";
			} else {
				String error = "User has not been assigned any projects currently";
				ErrorBean errorbean = new ErrorBean();
				errorbean.setMessage(error);
				request.setAttribute("errorbean", errorbean);
				page = "/ErrorDisplayContainer.jsp";
			}//end else
			
			request.getRequestDispatcher(page).forward(request, response);
			
		}// end if action PROJECT_LIST

		if (action.equals("LOGOUT")) {

			try{
			HttpSession session = request.getSession(false);
			session.invalidate();
			} catch(Exception e) 
			{
				
			}
			request.getRequestDispatcher("/LoginContainer.jsp").forward(
					request, response);
		}// End If action LOGOUT
		
	if(action.equals("")){
		
		
	}

	}// end do post

	/*
	 * private ErrorBean validateDefectBean(HttpServletRequest request,
	 * HttpServletResponse response) { return null; } }
	 */

	/**
	 * Initialization of the servlet. <br>
	 * 
	 * @throws ServletException
	 *             if an error occured
	 */
	public void init() throws ServletException {
		// Put your code here
	}
	
}
